package org.dey.controller;

import org.dey.pojo.Exercise;
import org.dey.pojo.Health;
import org.dey.pojo.PageVo;
import org.dey.service.HealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class HealthController {
    @Autowired
    HealthService healthService;

    @PostMapping(value = "Health.action/{pageNum}/{pageSize}")
    public PageVo<Health> queryExercise(@RequestBody Health health,
                                        @PathVariable int pageNum,
                                        @PathVariable int pageSize) {

        PageVo<Health> queryuser = healthService.queryHealth(health, pageNum, pageSize);
        return queryuser;
    }

    //添加
    @PostMapping("addHealth.action")
    public int insertHealth(@RequestBody Health health) {

        int insertuser = healthService.insertHealth(health);

        return insertuser;
    }

    @DeleteMapping("delHealth.action/{id}")
    public int deleteHealth(@PathVariable int id) {
        return healthService.deleteHealth(id);
    }

    @GetMapping("qureyHealthById.action/{id}")
    public Health queryHealthByid(@PathVariable int id) {
        return healthService.queryHealthByid(id);
    }

    @PutMapping("updataHealth.action")
    public int updateHealth(@RequestBody Health health) {
        return healthService.updateHealth(health);
    }
}
